package org.example.executor.statement;

import org.example.executor.Executor;
import org.example.mapping.BoundSql;
import org.example.mapping.MappedStatement;
import org.example.session.ResultHandler;
import org.example.session.RowBounds;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

public class RoutingStatementHandler extends BaseStatementHandler{

    private final StatementHandler delegate;

    public RoutingStatementHandler(Executor wrapper, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
        super(wrapper,  ms, parameter, rowBounds, resultHandler, boundSql);
        delegate = new PreparedStatementHandler(wrapper,  ms, parameter, rowBounds,resultHandler, boundSql);
    }

    @Override
    public <E> List<E> query(Statement statement, ResultHandler resultHandler) throws SQLException {
        return delegate.query(statement, resultHandler);
    }

    @Override
    public BoundSql getBoundSql() {
        return null;
    }

    public Statement prepare(Connection connection) throws SQLException {
        return delegate.prepare(connection);
    }


    @Override
    public void parameterize(Statement stmt) {
        delegate.parameterize(stmt);
    }
}
